<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tìm Kiếm</title>
</head>

<body>
<?
//tìm kiếm
// xuất exxcel
if(isset($_POST['smb'])){
		require_once "ExcelExport.php";
		include("../config/config.php");
		$xls = new ExcelExport();				
		$xls->download("websites.xls");
		$stt=0;	
	if(isset($_POST['ngay'])){
	$ngay = $_POST['ngay'];
	}else{$ngay ='';}
	if(isset($_POST['thang'])){
	$thang = $_POST['thang'];
	}else{$thang = '';}
	if(isset($_POST['nam'])){
	$nam = $_POST['nam'];
	}else{$nam = '';}
	
	$dt = $ngay."/".$thang."/".$nam;
	//echo $dt;
	mysql_query("SET NAME 'utf-8'");
	
		if($_POST['goi']==1){
		     $ma = "(maloaithe = '1')";
			}
		if($_POST['goi']==2){
		     $ma = "(maloaithe = '2')";
			}
			if($_POST['goi']==3){
		     $ma = "(maloaithe = '3')";
			}	
		if($_POST['goi']==123){
		     $ma = "(maloaithe = '123' or maloaithe = '132' or maloaithe = '213' or maloaithe = '231' or maloaithe = '321' or maloaithe = '312')";
			}
		if($_POST['goi']==12){
		     $ma = "(maloaithe = '12' or maloaithe = '21')";
			}
		if($_POST['goi']==13){
		     $ma = "(maloaithe = '13' or maloaithe = '31')";
			}
		if($_POST['goi']==23){
		     $ma = "(maloaithe = '23' or maloaithe = '32') ";
			}
		if($_POST['goi']==99){
		     $ma = "(maloaithe = '123' or maloaithe = '132' or maloaithe = '213' or maloaithe = '231' or maloaithe = '321' or maloaithe = '312' or maloaithe = '1' or maloaithe = '2' or maloaithe = '3' or maloaithe = '12' or maloaithe = '21' or maloaithe = '13' or maloaithe = '31' or maloaithe = '23' or maloaithe = '32') ";
			}	
			
		$sql1 = "SELECT * FROM `menu` WHERE ".$ma." and time ='".$dt."'";
		
		$result1 = mysql_query($sql1);
		//require_once "ExcelExport.php";		
		?>
		
		<table width="100%" border="1" align="center">
      <tr>
        <td width="30" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>STT</b></font></td>
        <td width="200" style="background-color: DarkGreen;"><font color="#ffffff"><b>Loại thẻ</b></font></td>
		<td width="200" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Họ tên</b></font></td>
		<td width="200" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Cmnd/Hộ Chiếu</b></font></td>
		<td width="120" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Email</b></font></td>
		<td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Số điện thoại</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Địa chỉ</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Khu vực</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Thu nhập</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Nghề nghiệp</b></font></td>
      </tr>
       
<?php

	while($n = mysql_fetch_array($result1))
	//print_r($n['2']);
	{
		//$n = $n-1;
	$stt++;
	?>
      <tr>
      <td align="center"><?php echo $stt;?></td>
        <td align="center"><?php echo $n['loaithe']?></td>
		<td align="center"><?php echo $n['hoten']?></td>
		<td align="center"><?php echo $n['cmnd']?></td>
		<td align="center"><?php echo $n['email']?></td>
		<td align="center"><?php echo $n['sdt']?></td>
        <td align="center"><?php echo $n['diachi']?></td>
        <td align="center"><?php echo $n['khuvuc']?></td>
        <td align="center"><?php echo $n['thunhap']?></td>
        <td align="center"><?php echo $n['nghe nghiep']?></td>
      </tr><?php }
	?>
    </table>
<?php }
// tìm kiếm
else if(isset($_POST['smbtim'])){?>
<table width="100%" border="1" align="center">
      <tr>
        <td width="30" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>STT</b></font></td>
        <td width="200" style="background-color: DarkGreen;"><font color="#ffffff"><b>Loại thẻ</b></font></td>
		<td width="200" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Họ tên</b></font></td>
		<td width="200" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Cmnd/Hộ Chiếu</b></font></td>
		<td width="120" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Email</b></font></td>
		<td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Số điện thoại</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Địa chỉ</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Khu vực</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Thu nhập</b></font></td>
        <td width="240" style="background-color: DarkGreen;" align="center"><font color="#ffffff"><b>Nghề nghiệp</b></font></td>
      </tr>
       
<?php
	include("../config/config.php");
	// tìm kiếm
	
	$stt=0;	
	if(isset($_POST['ngay'])){
	$ngay = $_POST['ngay'];
	}else{$ngay ='';}
	if(isset($_POST['thang'])){
	$thang = $_POST['thang'];
	}else{$thang = '';}
	if(isset($_POST['nam'])){
	$nam = $_POST['nam'];
	}else{$nam = '';}
	
	$dt = $ngay."/".$thang."/".$nam;
	//echo $dt;
	mysql_query("SET NAME 'utf-8'");
	
		if($_POST['goi']==1){
		     $ma = "(maloaithe = '1')";
			}
		if($_POST['goi']==2){
		     $ma = "(maloaithe = '2')";
			}
			if($_POST['goi']==3){
		     $ma = "(maloaithe = '3')";
			}	
		if($_POST['goi']==123){
		     $ma = "(maloaithe = '123' or maloaithe = '132' or maloaithe = '213' or maloaithe = '231' or maloaithe = '321' or maloaithe = '312')";
			}
		if($_POST['goi']==12){
		     $ma = "(maloaithe = '12' or maloaithe = '21')";
			}
		if($_POST['goi']==13){
		     $ma = "(maloaithe = '13' or maloaithe = '31')";
			}
		if($_POST['goi']==23){
		     $ma = "(maloaithe = '23' or maloaithe = '32')";
			}		
		if($_POST['goi']==99){
		     $ma = "(maloaithe = '123' or maloaithe = '132' or maloaithe = '213' or maloaithe = '231' or maloaithe = '321' or maloaithe = '312' or maloaithe = '1' or maloaithe = '2' or maloaithe = '3' or maloaithe = '12' or maloaithe = '21' or maloaithe = '13' or maloaithe = '31' or maloaithe = '23' or maloaithe = '32') ";
			}
		
		$sql = "SELECT * FROM `menu` WHERE ".$ma." and time ='".$dt."'";
		//echo $sql;die();
		//echo $sql;
		$result = mysql_query($sql);	
		
		// xuất ra excel
		
	while($n = mysql_fetch_array($result))
	//print_r($n['2']);
	{
		//$n = $n-1;
	$stt++;
	?>
      <tr>
      <td align="center"><?php echo $stt;?></td>
        <td align="center"><?php echo $n['loaithe']?></td>
		<td align="center"><?php echo $n['hoten']?></td>
		<td align="center"><?php echo $n['cmnd']?></td>
		<td align="center"><?php echo $n['email']?></td>
		<td align="center"><?php echo $n['sdt']?></td>
        <td align="center"><?php echo $n['diachi']?></td>
        <td align="center"><?php echo $n['khuvuc']?></td>
        <td align="center"><?php echo $n['thunhap']?></td>
        <td align="center"><?php echo $n['nghe nghiep']?></td>
      </tr><?php }
	}?>
    </table>

		
		
		
	
</body>
</html>